/*
 *    Copyright 2011-2020 enniu.com
 */
<#if localPackage?? && localPackage!="">
package ${localPackage}.service.impl;
</#if>


/**
* ${model.description}
*
* @author ${author} ${date}
* <#if email?? && email!="">E-mail:${email}</#if>
*/
@Service
public class ${XxxServiceImpl}{
	@Autowired
	private ${XxxDaoImpl} ${xxxDao};
	
    /**
     * 添加
     * @param ${xxxBean}
     * @return
     */
	public int add(${XxxBean} ${xxxBean}) {
		return ${xxxDao}.insert(${xxxBean});
	}
	
    /**
     * 更新
     * @param ${xxxBean}
     * @return
     */
	public int update(${XxxBean} ${xxxBean}) {
		return ${xxxDao}.update(${xxxBean});
	}
	
	/**
	 * 根据${id}删除
	 * @param ${id}
	 */
	public int deleteBy${Id}(${DataTypeAdapt.convert(model.keyProperty.clazzType)} ${id}) {
		int count = ${xxxDao}.deleteBy${Id}(${id});
		return count;
	}
	
    /**
     * ͨ根据${id}查询
     * @param ${id}
     * @return
     */
	public ${XxxBean} getBy${Id}(${DataTypeAdapt.convert(model.keyProperty.clazzType)} ${id}) {
		${XxxBean} ${xxxBean} = ${xxxDao}.selectBy${Id}(${id});
		return ${xxxBean};
	}

    /*
     * 获取分页数据
	 * @return
	 */
	public PageInfoDto getPageInfoDto(${XxxBean} ${xxxBean},int page, int perPage) {
        <#assign xxxPageInfo = NameConvert.convert2LowerHeadName(model.name)+"PageInfo"/>
        PageInfoDto ${xxxPageInfo} = new PageInfoDto(page, perPage); //创建pageinfo
        int count = ${xxxDao}.selectCount(${xxxBean});
        ${xxxPageInfo}.setCount(count);
		${xxxPageInfo}.setItems(${xxxDao}selectList(${xxxBean}, ${xxxPageInfo}.getStartIndex(), ${xxxPageInfo}.getPerPage()));
		return ${xxxPageInfo};
	}

}